//
//  YAYISendResumeListCell.m
//  YAYIDoctor
//
//  Created by Veer on 16/7/1.
//
//

#import "YAYISendResumeListCell.h"

#import "YAYISendResumeListModel.h"


@interface YAYISendResumeListCell()

@property (nonatomic, weak) UIImageView *iconView;
@property (nonatomic, weak) UILabel *nameLbl;
@property (nonatomic, weak) UILabel *addressLbl;
@property (nonatomic, weak) UIView *lineView;


@end

@implementation YAYISendResumeListCell

- (void)setModel:(YAYISendResumeListModel *)model
{
    _model = model;
    
    self.nameLbl.text = model.hospitalname;
    self.addressLbl.text = model.jobtitle;
    
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",API ,model.hospitalpicUrl];
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@""] options:SDWebImageRefreshCached];
    
}

+ (instancetype)cellWith:(UITableView *)tableview
{
    static NSString *cellID = @"myHospitalCell";
    
    YAYISendResumeListCell *cell = [tableview dequeueReusableCellWithIdentifier:cellID];
    
    if (nil == cell) {
        cell = [[YAYISendResumeListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
    }
    
    return cell;
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setupSubview];
        
    }
    return self;
}


- (void)setupSubview
{
    // 图标
    UIImageView *iconVw = [[UIImageView alloc] init];
    [self.contentView addSubview:iconVw];
    self.iconView = iconVw;
    
    // 医院名
    UILabel *nameLbl = [[UILabel alloc] init];
    nameLbl.font = [UIFont systemFontOfSize:17];
    [self.contentView addSubview:nameLbl];
    self.nameLbl = nameLbl;
    
    // 医院名
    UILabel *addressLbl = [[UILabel alloc] init];
    addressLbl.font = [UIFont systemFontOfSize:15];
    addressLbl.textColor = YAYIColor(116, 113, 113);
    [self.contentView addSubview:addressLbl];
    self.addressLbl = addressLbl;
    
    // 线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = YAYICellLineColor;
    [self.contentView addSubview:lineView];
    self.lineView = lineView;
    
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat margin = 15;
    // 设置frame
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(margin);
        make.bottom.mas_equalTo(-margin);
        make.left.mas_equalTo(margin);
        make.width.mas_equalTo(self.iconView.mas_height).multipliedBy(1.4);
    }];
    
    [self.nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(20);
        make.top.mas_equalTo(margin);
    }];
    
    [self.addressLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLbl);
        make.top.mas_equalTo(self.nameLbl.mas_bottom).offset(10);
        make.right.mas_equalTo(-20);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.width.mas_equalTo(SCREEN_width);
        make.left.mas_equalTo(0);
        make.bottom.equalTo(self.contentView);
    }];
}

@end

